package com.song.article.task;

import com.song.article.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;

//@Configuration      //  1. 标记配置类注入容器
//@EnableScheduling   //  2. 开启定时任务
public class TaskPublishArticle {

    @Autowired
    private ArticleService articleService;

    //3. 添加定时任务
    @Scheduled(cron = "0/10 * * * * ?")
    private void publishArticle() {
        articleService.updateAppointToPublish();
        //  System.out.println("执行定时任务: " + LocalDateTime.now());

    }
}

